package io.lkt.task.bus.service.impl;

import io.lkt.task.bus.mapper.UserBrandInfoMapper;
import io.lkt.task.bus.model.UserBrandInfo;
import io.lkt.task.bus.service.IUserBrandService;
import io.lkt.task.bus.service.SysGzhService;
import io.lkt.task.model.PlatformSysInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

@Component
@Service
public class UserBrandServiceImpl implements IUserBrandService {

    @Autowired
    private UserBrandInfoMapper userBrandInfoMapper;

//    @Value("${frontDomain}")
//    private String frontDomain;

    @Autowired
    private SysGzhService sysGzhService;

    @Override
    public List<UserBrandInfo> getUserSubBrandInfo(Integer userId) {
        return userBrandInfoMapper.queryUserSubBrandInfo(userId);
    }

    @Override
    public Integer getUserSubBrandCount(Integer userId) {
        return userBrandInfoMapper.queryUserSubBrandCount(userId);
    }

    @Override
    public String generateUserBrandSetPushMsg(Integer userId,String profile) {
        PlatformSysInfo sysGzh = sysGzhService.getPlatformSysInfo(profile);
        String articleAccessDomain =sysGzh.getFrontDomain();

        String pushMsg = "设置品牌，我们将为您精准推荐品牌文章\n" +
                "<a href='"+ articleAccessDomain +"/pages/article/editBrands.html'>点击设置品牌</a>";

        return pushMsg;
    }

    @Override
    public UserBrandInfo getUserSelectedBrandInfo(Integer userId) {
        return userBrandInfoMapper.queryUserSelectedBrandInfo(userId);
    }
}
